package com.tongjie.hotelbooking.sequence.repository;

import com.tongjie.hotelbooking.sequence.entity.Sequence;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

@Repository
public interface SequenceRepository extends JpaRepository<Sequence, Long>, JpaSpecificationExecutor<Sequence> {

    @Modifying
    @Query("update Sequence set currentValue = currentValue + stepLength where sequenceName = ?1")
    void updateCurrentValue(String sequenceName);

    Sequence getSequenceBySequenceName(String sequenceName);


}
